/**
 ********************************************************************
 * @author roocket
 * @file    sound_decode_mp3.h
 * @version V0.0.0
 * @date    2024/4/27
 * @brief   This file is to indicate decode mp3 functions. 
 * @attention Code file rules:
 * rule: file encoding use UTF8;
 * rule: max line length 120 characters;
 * rule: line separator \r\n;
 * rule: use clion auto code format tool.
 */

#ifndef _SOUND_DECODE_MP3_H_
#define _SOUND_DECODE_MP3_H_
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <poll.h>
#include <alsa/asoundlib.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
 FILE *outfile;
 /* definitions for audio */
struct sound_ffmpeg_player
{
    AVCodec *codec;
    AVCodecContext *codec_ctx;
    AVFrame *frame;
    AVCodecParserContext *parser;
    AVPacket *pkt;
};

/* init player for sound for ffmpeg */
int sound_ffmpeg_audio_player_init(struct sound_ffmpeg_player *aplayer);

/* decode mp3 by frame */
int sound_ffmpeg_audio_decode_mp3(struct sound_ffmpeg_player *aplayer, const char *mp3, int len);

/* deinit player for sound for ffmpeg */
int sound_ffmpeg_audio_player_deinit(struct sound_ffmpeg_player *aplayer);

#endif /* _SOUND_DECODE_MP3_H_ */
